package cn.fintecher.pangolin.service.business.model.request;

import cn.fintecher.pangolin.common.enums.CaseDataStatus;
import cn.fintecher.pangolin.entity.mysql.QCaseInfo;
import com.querydsl.core.BooleanBuilder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * @Author wangxiangdong
 * @Description 个人已分配request
 * @Date 2019/9/2 10:13
 **/
@Data
public class PersonalDistributedRequest {

    @ApiModelProperty("部门code")
    private String departmentCode;

    @ApiModelProperty("案件状态")
    private CaseDataStatus caseDataStatus;

    public BooleanBuilder generateQueryBuilder() {
        BooleanBuilder booleanBuilder = new BooleanBuilder();
        QCaseInfo caseInfo = QCaseInfo.caseInfo;
        if (Objects.nonNull(this.departmentCode)) {
            booleanBuilder.and(caseInfo.department.departCode.like(StringUtils.join(this.departmentCode,"%")));
        }
        if (Objects.nonNull(this.caseDataStatus)) {
            booleanBuilder.and(caseInfo.caseDataStatus.eq(caseDataStatus));
        }
        return booleanBuilder;
    }
}
